//
//  NetWorkHelper.h
//  HuaRun2
//
//  Created by admin on 17/8/30.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void (^SuccessBlock)(id object);
typedef void (^FailureBlock)(NSError *error);

@interface NetWorkHelper : NSObject

@property (nonatomic, copy) SuccessBlock successBlock;
@property (nonatomic, copy) FailureBlock failureBlock;

+ (NetWorkHelper *)shareNetWorkHelper;

/**
 *  发送get请求
 *
 *  @param urlString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param successBlock    请求成功的回调
 *  @param failureBlock    请求失败的回调
 */
+ (void)getWithURLString:(NSString *)urlString
              parameters:(id)parameters
                 success:(SuccessBlock)successBlock
                 failure:(FailureBlock)failureBlock;

/**
 *  发送post请求
 *
 *  @param urlString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param successBlock    请求成功的回调
 *  @param failureBlock    请求失败的回调
 */
+ (void)postWithURLString:(NSString *)urlString
               parameters:(id)parameters
                  success:(SuccessBlock)successBlock
                  failure:(FailureBlock)failureBlock;

/**
 *  上传图片(单张)
 *
 *  @param path    路径
 *  @param image   图片
 *  @param params  参数
 *  @param successBlock 成功回调
 *  @param failureBlock 失败回调
 */
+ (void)uploadImageWithPath:(NSString *)path
                      image:(UIImage *)image
                     params:(NSDictionary *)params
                    success:(SuccessBlock)successBlock
                    failure:(FailureBlock)failureBlock;

/**
 *  上传图片(多张)
 *
 *  @param path    路径
 *  @param photos  图片数组
 *  @param params  参数
 *  @param ocrId 第二次上传用此参数拼接到URL后面，第一次不用拼接
 *  @param successBlock 成功回调
 *  @param failureBlock 失败回调
 */
+ (void)uploadImageWithPath:(NSString *)path
                     photos:(NSArray *)photos
                     params:(NSDictionary *)params
                      ocrId:(NSString *)ocrId
                    success:(SuccessBlock)successBlock
                    failure:(FailureBlock)failureBlock;

//取消网络请求
+ (void)cancelAllRequest;

@end
